package com.ysx.server.mapper;

import com.github.pagehelper.Page;
import com.ysx.server.pojo.dto.CommentPageQueryDTO;
import com.ysx.server.pojo.entity.Comment;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author ysx
* @description 针对表【comment(评论表)】的数据库操作Mapper
* @createDate 2024-02-15 14:35:31
* @Entity com/ysx/server/pojo.domain.Comment
*/
@Mapper
public interface CommentMapper {
    /**
     * 分页查询
     * @param commentPageQueryDTO
     * @return
     */
    Page<Comment> page(CommentPageQueryDTO commentPageQueryDTO);

    /**
     * 修改评论信息
     * @param comment
     * @return
     */
    boolean update(Comment comment);

    /**
     * 通过id删除评论信息
     * @param id
     * @return
     */
    @Delete("delete from second_hand_trading.comment where id=#{id}")
    boolean deleteById(Long id);

    /**
     * 通过用户id查找评论
     * @param userId
     * @return
     */
    @Select("select * from second_hand_trading.comment where userId=#{userId}")
    List<Comment> getByUserId(Long userId);

    /**
     * 通过商品id获取评论信息
     * @param goodsId
     * @return
     */
    @Select("select * from second_hand_trading.comment where goodsId=#{goodsId} ")
    List<Comment> getByGoodsId(Long goodsId);

    /**
     * 新增评论
     * @param comment
     * @return
     */
    boolean add(Comment comment);
}




